/*sfvNt/4/BBx1n2Zrl55uA0X3rUh/aCnXfar/yaD3lFLmGv3NvzJcwoMty5tsZsGC*/

import { LIST_BUTTON, BUTTON_DISABLED, PAGECODE } from '../../constance';

//初始化列表页按钮状态（可用性、显隐性）
export default function (pageModel) {
    let rows = pageModel.get(PAGECODE.listTableId).getCheckedRows();
    // 初始化全部不可用
    let Delete = BUTTON_DISABLED;
    let Commit = BUTTON_DISABLED;
    let UnCommit = BUTTON_DISABLED;
    let Print = BUTTON_DISABLED;
    let Edit = BUTTON_DISABLED;

    if (rows && rows.length) {
        Delete = false;
        Commit = false;
        UnCommit = false;
        Print = false;
        if(rows.length === 1){
            Edit = false;
        }
    } else {
        Delete = true;
        Commit = true;
        UnCommit = true;
        Print = true;
        Edit = true;
    }
    let disableArr = {
        [LIST_BUTTON.Delete]: { "disabled": Delete }, //删除
        [LIST_BUTTON.Commit]: { "disabled": Commit }, //提交
        [LIST_BUTTON.UnCommit]: { "disabled": UnCommit }, //收回
        [LIST_BUTTON.Edit]: { "disabled": Edit }, //修改
        [LIST_BUTTON.Print]: { "disabled": Print }, //打印
    };
    pageModel.get(PAGECODE.listHeadBtnId).setItems(disableArr);
}
/*sfvNt/4/BBx1n2Zrl55uA0X3rUh/aCnXfar/yaD3lFLmGv3NvzJcwoMty5tsZsGC*/